Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add host status column #1774

Merged
merged 1 commit into from
Jul 1, 2019
Merged

Add host status column #1774

merged 1 commit into from
Jul 1, 2019

Conversation

jtomasek
Copy link

@jtomasek jtomasek commented Jun 20, 2019

  • Introduces BaremetalHostStatus component which renders appropriate status component based on host status
  • Introduces utility functions to determine host status (optionally also
    from host's machine and node)

Depends on #1697

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 20, 2019
@spadgett spadgett added this to the v4.2 milestone Jun 20, 2019
@jtomasek jtomasek mentioned this pull request Jun 21, 2019
status?: string;
};

export const GenericStatus: React.FC<{ status?: string }> = ({ status, children }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused. Why are we copying all this logic from utils/status-icon.tsx?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch depends on #1697 which among other things lets plugins re-use the StatusIconAndText functionality (I've tried to cover the motivation here #1697 (comment))

@spadgett
Copy link
Member

/hold

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 21, 2019
@jtomasek
Copy link
Author

I've updated this PR to not depend on #1697 and used existing StatusIconAndText component to unblock this PR and work that depends on it.

const hostStatus = getHostStatus(host);
const { status, title } = hostStatus;

switch (true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever, but is this really better than...?

if (status === HOST_STATUS_DISCOVERED) {
  return <AddDiscoveredHostButton host={host} />;
}
if (HOST_PROGRESS_STATES.includes(status)) {
  return <StatusIconAndText status={title} iconName="refresh" />;
}
// ...

Copy link
Author

@jtomasek jtomasek Jun 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion, but I find the switch statement a bit more readable

export const AddDiscoveredHostButton: React.FC<{ host: K8sResourceKind }> = (
{ host }, // eslint-disable-line @typescript-eslint/no-unused-vars
) => (
<Button bsStyle="link">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RBAC check?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

title: 'Status',
// sortField: 'spec.machineRef.name',
// transforms: [sortable],
props: { className: tableColumnClasses[1] },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice if this is sortable, but I don't think there's a way to add sortFunc from a plugin yet.

@@ -3,8 +3,8 @@ import * as _ from 'lodash';
import { K8sResourceKind, MachineKind } from '@console/internal/module/k8s';
import { getName } from '@console/shared';

export const getOperationalStatus = (host) => _.get(host, 'status.operationalStatus');
export const getProvisioningState = (host) => _.get(host, 'status.provisioning.state');
export const getHostOperationalStatus = (host) => _.get(host, 'status.operationalStatus');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not new, but it would be better to add types to all of these helper functions

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I'll create BaremetalHostKind for host in a separate PR.

// return NOT_HANDLED;
// };

type HostStatusResult = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be inferred from the return value, but I'm not against declaring it explicitly.

// node?: NodeKind,
): string => getHostStatus(host).status;

export const canHostAddMachine = (host) => [HOST_STATUS_READY].includes(getSimpleHostStatus(host));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declare types

@spadgett
Copy link
Member

/hold cancel

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 24, 2019
* Introduces BaremetalHostStatus component which renders appropriate
  status component based on host status
* Introduces utility functions to determine host status (optionally also
  from host's machine and node)
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 25, 2019
@honza
Copy link
Member

honza commented Jun 27, 2019

/approve
/lgtm

@openshift-ci-robot
Copy link
Contributor

@honza: changing LGTM is restricted to collaborators

In response to this:

/approve
/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@honza
Copy link
Member

honza commented Jun 28, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 28, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: honza, jtomasek, knowncitizen

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@jtomasek
Copy link
Author

/test e2e-aws
/test frontend

@jtomasek
Copy link
Author

jtomasek commented Jul 1, 2019

/test frontend

@openshift-merge-robot openshift-merge-robot merged commit 6df9297 into openshift:master Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants